/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package bean;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author Johann
 */

@ManagedBean
@ViewScoped
public class BeanLogin {

    @NotNull
    @Size(min = 6, max = 10)
    private String name;

    @NotNull
    @Size(min = 6, max = 10)
    private String password;

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return the password
     */
    public String getPassword() {
        return password;
    }

    /**
     * @param password the password to set
     */
    public void setPassword(String password) {
        this.password = password;
    }

    /**
     * Método que validará el usuario y la contraseña.
     */
    public String validateUser() {

        System.out.println("hhhhh: " + name);
        System.out.println(password);
        if (name.equals("Usuario1") && password.equals("password")) {
            return "index2.xhtml";
        } else {
            return "indexERROR.xhtml";
        }
        
    }
}
